rack one's brain wits

(為某事)絞盡腦汁,苦思冥想